from django.http import HttpResponse
from django.shortcuts import render
import logging
logger = logging.getLogger('django')
# Create your views here.
from django.views import View
from django_redis import get_redis_connection

from yuhuang.libs.captcha.captcha import captcha


class ImageCodeView(View):
    """图型验证码"""

    def get(self,request,uuid):

        text,image = captcha.generate_captcha()
        redis_coon = get_redis_connection('verify_code')

        redis_coon.setex('img_%s' % uuid, 300, text)
        logger.info(text)
        return HttpResponse(image,content_type='image/jpg')